package kr.co.hk.cp;

import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class ContentProviderActivity extends Activity {
	static final String WORDURI = "content://exam.Data.EnglishWord/word";
	EditText mText;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

		mText = (EditText)findViewById(R.id.edText);

		findViewById(R.id.readall).setOnClickListener(onClick);
    }
    
	View.OnClickListener onClick = new View.OnClickListener() {
		public void onClick(View v) {
			ContentResolver cr = getContentResolver();
			if(v.getId() == R.id.readall){
				Cursor cursor = cr.query(Uri.parse(WORDURI), 
						null, null, null, null);
				
				String Result = "";
				while (cursor.moveToNext()) {
					String eng = cursor.getString(0);
					String han = cursor.getString(1);
					Result += (eng + " = " + han + "\n");
				}

				if (Result.length() == 0) {
					mText.setText("Empyt Set");
				} else {
					mText.setText(Result);
				}
				cursor.close();
			}
		}
	};
}





